<script setup lang="ts">
    // import { useRouter } from "uni-mini-router"
    // import { useReadHistoryStore } from "@/state/readHistory"

    // const readHistoryStore = useReadHistoryStore()
    // const router = useRouter()
    // const id = readHistoryStore.lastReadBookId ?? "1001"
    // const page = readHistoryStore.getReadPage(id) ?? 0

    import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
    import { useTabBarStore } from "@/state/tabBarConfig"

    const tabBarStore = useTabBarStore()

    onLaunch(async () => {
        // router.push(`/pages/read?id=${id}&page=${page}`)
        console.log("App Launch")
        
        // 初始化TabBar配置（从服务器获取是否显示概率游戏）
        await tabBarStore.initTabBarConfig()
        
        // 如果不显示概率游戏，跳转到书架页面
        if (!tabBarStore.showGame) {
            console.log("概率游戏未启用，跳转到书架页面")
            uni.reLaunch({
                url: '/pages/books'
            })
        }
    })
    onShow(() => {
        console.log("App Show")
    })
    onHide(() => {
        console.log("App Hide")
    })
</script>

<style lang="scss">
    view,
    text,
    img,
    input {
        box-sizing: border-box;
    }

    page {
        width: 100%;
        height: 100%;
    }
</style>
